from django.contrib.auth.mixins import LoginRequiredMixin

from django.http import JsonResponse
from ihome.utils import statusCode


class LoginRequiredJSONMixin(LoginRequiredMixin):

    """自定义LoginRequiredMixin
    如果用户未登录，响应JSON，且状态码为4101
    """

    def handle_no_permission(self):
        return JsonResponse({'errno': statusCode.SESSIONERR, 'errmsg': '未登录'})



